<template>
  <el-card class="card">
    <div class="s_box bottom">
      <el-input class="s_item" placeholder="请输入类别名称..." v-model="query.name" clearable @clear="reset"></el-input>
      <el-button type="primary" :icon="Search" @click="initAssetListByName">查询</el-button>
      <el-button type="info" :icon="Setting" @click="reset">重置</el-button>
    </div>
    <el-table
            ref="tableDataRef"
            :data="tableData"
            border stripe
            style="width: 100%"
            :cell-style="{textAlign: 'center'}"
            :header-cell-style="{textAlign: 'center'}"
    >
      <el-table-column type="selection" width="55"/>
      <el-table-column prop="id" label="索引" width="80"/>
      <el-table-column prop="name" label="类别名称"/>
      <el-table-column prop="describes" label="类别描述"/>
    </el-table>
  </el-card>
</template>

<script setup>
import { ref } from "vue"
import request from "@/util/request";
import { Search, Setting } from "@element-plus/icons-vue";

const tableData = ref([]);

const query = ref({
  name: "",
})

const initAssetTypeList = async () => {
  const res = await request.get("assetType/list");
  console.log(res.data.assetTypeList)
  tableData.value = res.data.assetTypeList;
}
initAssetTypeList();

const initAssetListByName = async () => {
  const res = await request.post("assetType/listByName", query.value.name);
  tableData.value = res.data.assetTypeList;
}

/**
 * 清空选项
 */
const reset = () => {
  queryForm.value.map.zcmc = "";
  queryForm.value.map.zcmc = "";
  queryForm.value.map.type_Id = "";
  initAssetTypeList();
}
</script>

<style lang="scss" scoped>
.card {
  border: none;
  border-radius: 0;
  box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
}

::v-deep th.el-table__cell {
  word-break: break-word;
  background-color: #f8f8f9 !important;
  color: #515a6e;
  height: 40px;
  font-size: 15px;
}

.bottom {
  margin-bottom: 15px;
}

.s_box {
  display: flex;
  width: 30%;

  .s_item {
    flex: 1;
    margin-right: 15px;
  }
}
</style>